package com.woniu.smallmedical.controller;

import com.woniu.smallmedical.entity.PatientInformation;
import com.woniu.smallmedical.entity.Physique;
import com.woniu.smallmedical.entity.ResponseResult;
import com.woniu.smallmedical.server.PatientInformationServer;
import com.woniu.smallmedical.server.PhysiqueServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PhysiqueController {
    @Autowired
    PhysiqueServer physiqueServer;
    @Autowired
    PatientInformationServer patientInformationServer;

    @PostMapping("/addPhysique/{patientnumber}")
    public ResponseResult addPhysique(@RequestBody Physique physique,@PathVariable int patientnumber){
        System.out.println("体能信息====="+physique);
        System.out.println("患者编号====="+patientnumber);
        PatientInformation p = patientInformationServer.getPatByPatnum(patientnumber);
        System.out.println("患者信息======"+p);
        Physique phy = new Physique();
        phy.setBlood(physique.getBlood());
        phy.setBreathe(physique.getBreathe());
        phy.setFat(physique.getFat());
        phy.setGlucose(physique.getGlucose());
        phy.setHeat(physique.getHeat());
        phy.setHeight(physique.getHeight());
        phy.setPatientinformation(p.getPaid());
        phy.setPulse(physique.getPulse());
        phy.setWeight(physique.getWeight());
        physiqueServer.addPhysique(phy);
        return new ResponseResult(null,200,"体能信息！");
    }
}
